package node.exp;

import grammar.Lexer;
import lexical.Word;
import node.Node;
import symbol.SymbolTable;

public class Number implements Node {
    private final Lexer lexer;
    private final SymbolTable table;
    private final Node father;
    private Word number;

    public Number(Lexer lexer, SymbolTable table, Node father) {
        this.lexer = lexer;
        this.table = table;
        this.father = father;
        parseNumber();
    }

    private void parseNumber() {
        number = lexer.getCurWord(); // intcon
    }

    public int getValue() {
        return Integer.parseInt(number.word);
    }

    @Override
    public Node getFather() {
        return father;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(number.toString());
        return sb.append("<Number>\n").toString();
    }

    @Override
    public String genMidCode() {
        return number.word;
    }
}

